/**
 * 
 */
package gui;

import java.util.ArrayList;

import javax.swing.JFrame;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JTabbedPane;
import javax.swing.JButton;
import javax.swing.LayoutStyle.ComponentPlacement;

import data.Task;

import properties.DefaultProperties;
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @author Kevin
 *
 */
public class EditPatternWindow extends JFrame {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 8474094344559151867L;

	/**
	 * @param props the properties
	 * @param tasks the tasks
	 * @param mw mainwindow
	 * 
	 */
	public EditPatternWindow(DefaultProperties props, ArrayList<Task> tasks, MainWindow mw) {
		setMinimumSize(new Dimension(800, 600));
		setSize(new Dimension(800, 600));
		setPreferredSize(new Dimension(800, 600));
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		getContentPane().setSize(new Dimension(800, 600));
		
		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		
		JButton btnNewButton = new JButton("New button");
		
		JButton closeBtn = new JButton(props.getLocalizedText("close"));
		closeBtn.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				EditPatternWindow.this.dispose();
				
			}
		});
		GroupLayout groupLayout = new GroupLayout(getContentPane());
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap()
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addGroup(groupLayout.createSequentialGroup()
							.addComponent(btnNewButton)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(closeBtn))
						.addComponent(tabbedPane, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 414, Short.MAX_VALUE))
					.addContainerGap())
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.TRAILING)
				.addGroup(groupLayout.createSequentialGroup()
					.addComponent(tabbedPane, GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(closeBtn)
						.addComponent(btnNewButton))
					.addContainerGap())
		);
		
		JPanel panel = new EditPatternPanel(props, tasks, mw);
		tabbedPane.addTab("Edit Pattern", null, panel, null);
		getContentPane().setLayout(groupLayout);
		this.setVisible(true);
	}
}
